/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Bean;

import Model.Business.Business;
import Model.Entity.Account;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

/**
 *
 * @author CUONGTROC
 */
@ManagedBean
@SessionScoped
public class LoginBean {

    /** Creates a new instance of LoginBean */
    public LoginBean() {
    }
    Account acc = new Account();

    public Account getAccount() {
        return acc;
    }

    public void setAccount(Account account) {
        this.acc = account;
    }
    
    public String login()throws Exception{
        String result ="";
        try {
            if (acc != null) {
                acc = Business.getAccount(acc);
                if (acc.getEmail() != null) {
                    result="Home.xhtml";
                }
                else
                    result="login1.xhtml";
            }
        } catch (Exception ex) {
            throw ex;
        }
        return result;
    }
    public String addAccount()throws Exception{
        try {
       acc=Business.addAccount(acc);
        } catch (Exception e) {
        }
        return null;
    }
}
